package  
{
	import org.flixel.*;
	import org.flixel.plugin.photonstorm.*;
	
	/**
	 * ...
	 * @author le-ray_y
	 */
	public class UI extends FlxSprite
	{
		//************************************************************************
		//** 							VARIABLES								**
		//************************************************************************
		
		// UI Graph
		[Embed(source = '../../Assets/interface.png')]
		private var _UIClass:Class;
		
		// Armor Graph
		[Embed(source = '../../Assets/btn_armor.png')]
		private var _armorClass:Class;
		public var _armor:Upgrades;
		
		// Regen Graph
		[Embed(source = '../../Assets/btn_regen.png')]
		private var _regenClass:Class;
		public var _regen:Upgrades;
		
		// ?Spine? / Thorns Graph
		[Embed(source = '../../Assets/btn_spines.png')]
		private var _spineClass:Class;
		public var _spine:Upgrades;
		
		// Bow Graph
		[Embed(source = '../../Assets/btn_archer.png')]
		private var _bowClass:Class;
		public var _bow:Upgrades;
		
		// Soul Graph
		[Embed(source = '../../Assets/btn_soul.png')]
		private var _soulClass:Class;
		public var _soul:Upgrades;
		
		// Gas Graph
		[Embed(source = '../../Assets/btn_poison.png')]
		private var _gasClass:Class;
		public var _gas:Upgrades;
		
		// Minion Graph
		[Embed(source = '../../Assets/btn_minion.png')]
		private var _minionClass:Class;
		public var _minion:Upgrades;
		
		// Oil Graph
		[Embed(source = '../../Assets/btn_oil.png')]
		private var _oilClass:Class;
		public var _oil:Upgrades;
		
		// Healthbar
		public var _hpBar:FlxBar;
		
		// Score Text
		public var _score:FlxText;
		
		// Credits Text
		public var _credit:FlxText;
		
		//************************************************************************
		//** 							FUNCTIONS								**
		//************************************************************************
		public function UI()
		{
			// UI
			loadGraphic(_UIClass);
			
			// Armor, Regen, Thorn, Bow, Souls Graph
			_armor = new Upgrades(6, 6, _armorClass, 60, 60, false, Global.tower._healthLevel);
			_regen = new Upgrades(72, 6, _regenClass, 60, 60, false, Global.tower._regenLevel);
			_spine = new Upgrades(138, 6, _spineClass, 60, 60, false, Global.tower._spineLevel);
			_bow = new Upgrades(204, 6, _bowClass, 60, 60, false, Global.tower._bowLevel);
			_soul = new Upgrades(270, 6, _soulClass, 60, 60, false, Global.tower._soulLevel);
			
			// Skill buttons Gas, Rabbit Minion, and Oil
			_gas = new Upgrades(352, 6, _gasClass, 60, 60, true, 0, true, onGasClick);
			_minion = new Upgrades(418, 6, _minionClass, 60, 60, true, 0, true, onMinionClick);
			_oil = new Upgrades(486, 6, _oilClass, 60, 60, true, 0, true, onOilClick);
			
			// Health Bar
			_hpBar = new FlxBar(618, 15, FlxBar.FILL_LEFT_TO_RIGHT, 174, 20, Global.tower, "health", 0, Global.tower._maxHealth, true);
			_hpBar.dirty = true;
			
			// Credit Text
			_credit = new FlxText(150, 566, 175, "0");
			_credit.size = 20;
			
			// Score Text
			_score = new FlxText(550, 566, 175, "0");
			_score.size = 20;
		}
		

		/**
		 * Adds all of the UI elements buttons, text...
		 **/
		public function add():void
		{
			FlxG.state.add(_armor);
			FlxG.state.add(_armor._costText);
			FlxG.state.add(_regen);
			FlxG.state.add(_regen._costText);
			FlxG.state.add(_spine);
			FlxG.state.add(_spine._costText);
			FlxG.state.add(_bow);
			FlxG.state.add(_bow._costText);
			FlxG.state.add(_soul);
			FlxG.state.add(_soul._costText);
			FlxG.state.add(_gas);
			FlxG.state.add(_gas._costText);
			FlxG.state.add(_minion);
			FlxG.state.add(_minion._costText);
			FlxG.state.add(_oil);
			FlxG.state.add(_oil._costText);
			FlxG.state.add(_hpBar);
			FlxG.state.add(_score);
			FlxG.state.add(_credit);
		}
		
		public function test():void
		{
			_armor.exists = true;
			_regen.exists = true;
			_spine.exists = true;
			_bow.exists = true;
			_soul.exists = true;
			_gas.exists = true;
			_minion.exists = true;
			_oil.exists = true;
		}
		
		private function onGasClick(obj:*, x:Number, y:Number):void 
		{
			trace ("test");
		}
		
		private function onMinionClick(obj:*, x:Number, y:Number):void 
		{
			trace ("test");
		}
		
		private function onOilClick(obj:*, x:Number, y:Number):void 
		{
			trace ("test");
		}
	}

}